package com.kifas.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @author brainmaster
 * 
 */
@Entity
@Table(name = "tb_users")
public class UserEntity implements Serializable {

	private static final long serialVersionUID = -7415918431373352494L;

	@Id
	@Column(name = "user_name", nullable = false)
	private String username;

	@Column(name = "secret_code", nullable = false)
	private String secretCode;

	private String firstName;

	private String lastName;

	@Column(nullable = false)
	private String email;

	@Column(name = "created_by")
	private String createdBy;

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "tb_user_group", joinColumns = { @JoinColumn(name = "user_name", referencedColumnName = "user_name") }, 
			inverseJoinColumns = { @JoinColumn(name = "id_group", referencedColumnName = "id_group") })
	private List<GroupEntity> groups;

	public UserEntity() {
	}

	public UserEntity(String username, String secretCode, String firstName, String lastName, String email, String createdBy) {
		this.username = username;
		this.secretCode = secretCode;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.createdBy = createdBy;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getSecretCode() {
		return secretCode;
	}

	public void setSecretCode(String secretCode) {
		this.secretCode = secretCode;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setGroups(List<GroupEntity> groups) {
		this.groups = groups;
	}

	public List<GroupEntity> getGroups() {
		return groups;
	}

}
